/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package org.redkalex.htdi.base;

import javax.persistence.*;
import org.redkale.convert.*;
import org.redkale.convert.json.JsonConvert;
import org.redkale.source.VirtualEntity;

/**
 * 一直缓存在内存的用户基本信息
 *
 * @author zhangjx
 */
@VirtualEntity(loader = UserInfoLoader.class)
public class UserInfo {

    //状态间隔10，便于以后扩展意义接近的状态值比较靠近
    //正常
    public static final short STATUS_NORMAL = 10;

    //待审批
    public static final short STATUS_PENDING = 20;

    //审批不通过
    public static final short STATUS_PENDNO = 30;

    //冻结
    public static final short STATUS_FREEZE = 40;

    //隐藏
    public static final short STATUS_HIDDEN = 50;

    //关闭
    public static final short STATUS_CLOSED = 60;

    //过期
    public static final short STATUS_EXPIRE = 70;

    //删除
    public static final short STATUS_DELTED = 80;

    @Id
    @Column(comment = "[用户ID] 值从10001开始")
    protected int userid;  //用户ID

    @Column(length = 128, comment = "姓")
    protected String firstName = "";  //用户昵称

    @Column(length = 128, comment = "名")
    protected String lastName = "";

    @Column(length = 128, comment = "密码")
    protected String password = "";

    @Column(length = 128, comment = "邮箱地址")
    protected String email = "";

    @Column(comment = "[状态]: 10:正常;20:待审批;30:审批不通过;40:冻结;50:隐藏;60:关闭;70:过期;80:删除;")
    protected short status;

    @Column(updatable = false, comment = "[创建时间]")
    protected long createtime;

    public boolean checkAuth(int moduleid, int actionid) {
        return true;
    }

    public int getUserid() {
        return userid;
    }

    public void setUserid(int userid) {
        this.userid = userid;
    }

    public String getFirstName() {
        return firstName;
    }

    public void setFirstName(String firstName) {
        this.firstName = firstName;
    }

    public String getLastName() {
        return lastName;
    }

    public void setLastName(String lastName) {
        this.lastName = lastName;
    }

    @ConvertColumn(ignore = true, type = ConvertType.JSON)
    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public short getStatus() {
        return status;
    }

    public void setStatus(short status) {
        this.status = status;
    }

    public long getCreatetime() {
        return createtime;
    }

    public void setCreatetime(long createtime) {
        this.createtime = createtime;
    }

    @Override
    public String toString() {
        return JsonConvert.root().convertTo(this);
    }
}
